package com.huangpeng.designmodel.dubbo;

import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * @Author hp
 * @Title 消费者
 * @Package
 * @Date 2022/1/19 16:22
 * @Description
 * @Version 1.0
 */
public class Consumer {
    public static void main(String[] args) throws Exception {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] { "applicationContext-dubbo-consumer.xml" });
        context.start();
        DemoService demoService = (DemoService) context.getBean("demoService");
        String hello = demoService.sayHello("huangpeng");
        System.out.println("########### " + hello);
        List list = demoService.getUsers();
        if(!CollectionUtils.isEmpty(list)){
            for (int i = 0; i < list.size(); i++) {
                System.out.println("########### " + list.get(i).toString());
            }
        }
        System.in.read();
    }
}
